import 'package:flutter/material.dart';
import 'package:wheel_of_fortune/utils/utils.dart';
import 'package:wheel_of_fortune/widgets/customer_button.dart';

import 'counter.dart';

class RedeemOrBuyCandy extends StatefulWidget {
  /// 0- Redeem Candy  1- Buy Candy
  final type;
  RedeemOrBuyCandy({this.type=0,Key key}) : super(key: key);

  @override
  _RedeemOrBuyCandyState createState() => _RedeemOrBuyCandyState();
}

class _RedeemOrBuyCandyState extends State<RedeemOrBuyCandy> {
  int _count = 1;
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 437,
      color: whiteColor,
      child: SingleChildScrollView(
        child: Column(
          // crossAxisAlignment: CrossAxisAlignment.end,
          children: [
            Padding(
              padding: EdgeInsets.fromLTRB(27, 41, 27, 0),
              child: Text(
                widget.type == 0? 'Redeem Candy':'Buy Candy',
                style: TextStyle(
                  color: mainColor,
                  fontSize: 24,
                  fontFamily: 'Avenir Next LT Pro',
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(27, 30, 27, 0),
              child: Text(
                "1 Candy : 1 Peso",
                style: TextStyle(
                  color: Color(0xFFFF0000),
                  fontSize: 12,
                  fontFamily: 'Avenir Next LT Pro',
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(27, 29, 27, 0),
              child: Text(
                "I want to ${widget.type==0?'redeem':'buy'}",
                style: TextStyle(
                  color: mainColor,
                  fontSize: 14,
                  fontFamily: 'Avenir Next LT Pro',
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(66, 16, 66, 0),
              child: Counter(
                callBack: (count) {
                  setState(() {
                    _count = count;
                  });
                },
              ),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(27, 16, 27, 16),
              child: Text(
                "Candy",
                style: TextStyle(
                  color: mainColor,
                  fontSize: 14,
                  fontFamily: 'Avenir Next LT Pro',
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
            Padding(
              padding: EdgeInsets.only(bottom: 0),
              child: Container(
                height: 0.5,
                color: greyDBColor,
              ),
            ),
            Padding(
              padding: EdgeInsets.only(
                left: 110,
                top: 20,
              ),
              child: Container(
                child: Text.rich(
                  TextSpan(children: [
                    TextSpan(
                        text: 'Total Amount:',
                        style: TextStyle(
                          color: mainColor,
                          fontSize: 16,
                          fontFamily: 'Avenir Next LT Pro',
                          fontWeight: FontWeight.bold,
                        )),
                    TextSpan(
                        text: ' ₱${_count * 10}',
                        style: TextStyle(
                          color: yellowColor,
                          fontSize: 16,
                          fontFamily: 'Avenir Next LT Pro',
                          fontWeight: FontWeight.bold,
                        )),
                  ]),
                  textAlign: TextAlign.right,
                ),
              ),
            ),
            Padding(
              padding: EdgeInsets.only(top: 85),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                children: [
                  BgButton(
                    title: widget.type==0?'Redeem':'Buy',
                    color: deepYellowColor,
                    onTap: () => Navigator.of(context).pop(false),
                  ),
                  BorderButton(
                    title: 'Cancel',
                    color: deepYellowColor,
                    onTap: () => Navigator.of(context).pop(true),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
